package com.cci.kangdao.controller.rv;

import com.cci.kangdao.dto.BaseResponse;
import com.cci.kangdao.service.WorkOrderIndividualCasesService;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @description:
 * @author: joe
 * @company: CTY
 * @since: 2023/9/15 16:34
 * @version: V1.0
 **/
@Controller
@RequestMapping("individualCases")
public class WorkOrderIndividualCasesController {
    private Logger log = Logger.getLogger(this.getClass().getName());

    @Resource
    private WorkOrderIndividualCasesService workOrderIndividualCasesService;

    /**
     * 获取  服务工单详情 点击超时的详情
     *
     * @param orderId
     * @return
     */
    @RequestMapping(value = "getIndividualCases.aspx", method = RequestMethod.GET)
    @ResponseBody
    public BaseResponse getIndividualCases(@RequestParam("orderId") Long orderId, @RequestParam(value = "roleNo", required = false) String roleNo, HttpServletRequest request) {
        if (null == orderId) {
            return BaseResponse.error(-99, "请输入orderId");
        }
        if (StringUtils.isBlank(roleNo)) {
            return BaseResponse.error(-99, "请输入角色编号");
        }
        return workOrderIndividualCasesService.getIndividualCases(orderId, roleNo, request);
    }

    /**
     * 保存或者更新超时记录
     *
     * @param paramStr
     * @return
     */
    @RequestMapping(value = "workOrderReasonSaveOrUpdate.aspx", method = RequestMethod.POST)
    @ResponseBody
    public BaseResponse workOrderReasonSaveOrUpdate(@RequestBody String paramStr) {
        if (StringUtils.isBlank(paramStr)) {
            return BaseResponse.error(-99, "参数不能为空");
        }
        log.info("workOrderReasonSaveOrUpdate接口传参：" + paramStr);
        return workOrderIndividualCasesService.workOrderReasonSaveOrUpdate(paramStr);
    }

}
